/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_REMINDER_STORE_STRATEGY_H
#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_REMINDER_STORE_STRATEGY_H

#include "reminder_request.h"

#include "result_set.h"
#include "values_bucket.h"

namespace OHOS::Notification {
class ReminderBaseStrategy {
public:
    ReminderBaseStrategy() = default;
    virtual ~ReminderBaseStrategy() = default;

    /**
     * @brief Store the reminder to the database.
     */
    virtual void StoreToRdb(const sptr<ReminderRequest>& reminder, NativeRdb::ValuesBucket& baseValues,
        NativeRdb::ValuesBucket& values) = 0;

    /**
     * @brief Restore the reminder from the database.
     */
    virtual sptr<ReminderRequest> RestoreFromRdb(const std::shared_ptr<NativeRdb::ResultSet>& baseResults,
        const std::shared_ptr<NativeRdb::ResultSet>& results) = 0;

    /**
     * @brief Get table name.
     */
    virtual std::string GetTableName() = 0;

    /**
     * @brief Get table columns.
     */
    virtual std::string GetTableColumns() = 0;

protected:
    /**
     * @brief Store the reminder to the database(base).
     */
    void StoreToRdb(const sptr<ReminderRequest>& reminder, NativeRdb::ValuesBucket& values);

    /**
     * @brief Restore the reminder from the database(base).
     */
    void RestoreFromRdb(sptr<ReminderRequest>& reminder, const std::shared_ptr<NativeRdb::ResultSet>& results);

private:
    /**
     * @brief Restore the time related fields from the database.
     */
    void RestoreTime(sptr<ReminderRequest>& reminder, const std::shared_ptr<NativeRdb::ResultSet>& results);
    /**
     * @brief Restore the id related fields from the database.
     */
    void RestoreId(sptr<ReminderRequest>& reminder, const std::shared_ptr<NativeRdb::ResultSet>& results);
    /**
     * @brief Restore the context related from the database.
     */
    void RestoreContext(sptr<ReminderRequest>& reminder, const std::shared_ptr<NativeRdb::ResultSet>& results);
};

class ReminderTimerStrategy : public ReminderBaseStrategy {
public:
    ReminderTimerStrategy() = default;
    ~ReminderTimerStrategy() = default;

    /**
     * @brief Store the reminder to the database.
     */
    void StoreToRdb(const sptr<ReminderRequest>& reminder, NativeRdb::ValuesBucket& baseValues,
        NativeRdb::ValuesBucket& values) override;

    /**
     * @brief Restore the reminder from the database.
     */
    sptr<ReminderRequest> RestoreFromRdb(const std::shared_ptr<NativeRdb::ResultSet>& baseResults,
        const std::shared_ptr<NativeRdb::ResultSet>& results) override;

    /**
     * @brief Get table name.
     */
    std::string GetTableName() override;

    /**
     * @brief Get table columns.
     */
    std::string GetTableColumns() override;
};

class ReminderAlarmStrategy : public ReminderBaseStrategy {
public:
    ReminderAlarmStrategy() = default;
    ~ReminderAlarmStrategy() = default;

    /**
     * @brief Store the reminder to the database.
     */
    void StoreToRdb(const sptr<ReminderRequest>& reminder, NativeRdb::ValuesBucket& baseValues,
        NativeRdb::ValuesBucket& values) override;

    /**
     * @brief Restore the reminder from the database.
     */
    sptr<ReminderRequest> RestoreFromRdb(const std::shared_ptr<NativeRdb::ResultSet>& baseResults,
        const std::shared_ptr<NativeRdb::ResultSet>& results) override;

    /**
     * @brief Get table name.
     */
    std::string GetTableName() override;

    /**
     * @brief Get table columns.
     */
    std::string GetTableColumns() override;
};

class ReminderCalendarStrategy : public ReminderBaseStrategy {
public:
    ReminderCalendarStrategy() = default;
    ~ReminderCalendarStrategy() = default;

    /**
     * @brief Store the reminder to the database.
     */
    void StoreToRdb(const sptr<ReminderRequest>& reminder, NativeRdb::ValuesBucket& baseValues,
        NativeRdb::ValuesBucket& values) override;

    /**
     * @brief Restore the reminder from the database.
     */
    sptr<ReminderRequest> RestoreFromRdb(const std::shared_ptr<NativeRdb::ResultSet>& baseResults,
        const std::shared_ptr<NativeRdb::ResultSet>& results) override;

    /**
     * @brief Get table name.
     */
    std::string GetTableName() override;

    /**
     * @brief Get table columns.
     */
    std::string GetTableColumns() override;

private:
    /**
     * @brief Restore the time related fields from the database.
     */
    void RestoreTime(sptr<ReminderRequest>& reminder, const std::shared_ptr<NativeRdb::ResultSet>& results);
};
}  // namespace OHOS::Notification
#endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_REMINDER_STORE_STRATEGY_H